package com.bf.zk.node;

import java.awt.Dimension;
import org.eclipse.swt.graphics.Font;
import java.awt.Toolkit;

import javax.swing.JFrame;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

import com.bf.zk.MainWindow;
import com.bf.zk.constants.Constants;

public class ZkNode  {
	private JFrame parent;
	public ZkNode(final JFrame parent, boolean modal) {
		this.parent = parent;
		Display display=new Display(); 
        final Shell shell=new Shell(display,SWT.DIALOG_TRIM | SWT.ON_TOP ); 
        shell.setText("ZNZK");
        Dimension   screensize   =   Toolkit.getDefaultToolkit().getScreenSize();
        int width = (int)screensize.getWidth();
        int height = (int)screensize.getHeight();
       shell.setSize(width, height-65);
        //shell.setSize(1000,600);
       shell.setLocation(0, 0);
        Label label=new Label(shell,SWT.LEFT); 
        label.setText(Constants.ZKName);
        label.setBounds(25, 5, 400, 50);
        label.setFont(new Font(display, "微软雅黑",20,16));
        Button button0=new Button(shell,SWT.BORDER); 
        button0.setBounds(width-160,5,150,50);           
        button0.setText("退出"); 
        button0.setFont(new Font(display, "微软雅黑",20,16));
//        Button button=new Button(shell,SWT.BORDER); 
//       button.setBounds(width-230,5,100,25);        
//        button.setText("登录"); 
        
        final Browser browser=new Browser(shell,SWT.FILL); 
        browser.setBounds(5,60,width-20,height-170); 
        final String input=Constants.ZKURL;
        
//        button.addListener(SWT.Selection, new Listener() { 
//            public void handleEvent(Event event) { 
//                //String input="http://10.2.124.203/crm"; 
//                browser.setUrl(input); 
//            } 
//        }); 
        button0.addListener(SWT.Selection, new Listener() { 
            public void handleEvent(Event event) {
           	Constants.LGmin.setVisible(true);
           	Constants.ZKName="";
                shell.close(); 
            } 
        }); 
        shell.open(); 
        browser.setUrl(input);
        while (!shell.isDisposed()) { 
            if (!display.readAndDispatch()) 
              display.sleep(); 
          } 
          display.dispose(); 
          Constants.LGmin.setVisible(true);
	}

}
